package com.dlc.shop.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dlc.shop.bean.dto.WarehouseDTO;
import com.dlc.shop.bean.model.Warehouse;
import com.dlc.shop.bean.vo.WarehouseVO;
import com.dlc.shop.common.util.PageParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.stream.Stream;

/**
 *
 *
 * @author FrozenWatermelon
 * @date 2023-11-08 11:11:44
 */
public interface WarehouseMapper extends BaseMapper<Warehouse> {

    /**
     * 获取列表
     * @param warehouse 仓库参数
     * @return 列表
     */
    List<WarehouseVO> list(PageParam pageDTO, @Param("warehouse") WarehouseDTO warehouse);

    /**
     * 获取可配送仓库列表
     * @param warehouseDTO 仓库dto
     * @return 仓库列表
     */
    List<WarehouseVO> listCanDeliveryWarehouse(@Param("warehouseDTO")WarehouseDTO warehouseDTO);

    /**
     * 根据id获取
     *
     * @param warehouseId id
     * @return
     */
    WarehouseVO getByWarehouseId(@Param("warehouseId") Long warehouseId);

    /**
     * 保存
     * @param warehouse
     */
    void save(@Param("warehouse") Warehouse warehouse);

    /**
     * 更新
     * @param warehouse
     */
    void update(@Param("warehouse") Warehouse warehouse);

    /**
     * 根据id删除
     * @param warehouseId
     */
    void deleteById(@Param("warehouseId") Long warehouseId);

    /**
     * 根据仓库id获取对应供货城市
     *
     * @param warehouseId 仓库id
     * @return
     */
    List<Long> getWarehouseAreaByWarehouseId(@Param("warehouseId") Long warehouseId);

    /**
     * 统计该仓库名称使用的数量
     *
     * @param shopId      店铺id
     * @param warehouseName   仓库名称
     * @param sysType     系统类型
     * @param warehouseId 运费模板id
     * @return 使用的数量
     */
    int countByWarehouseName(@Param("shopId") Long shopId, @Param("warehouseName") String warehouseName, @Param("sysType") Integer sysType, @Param("warehouseId") Long warehouseId);


    /**
     * 统计之前保存的供应城市id
     * @param shopId
     * @param sysType
     * @param warehouseId
     * @return
     */
    List<Long> listareaByShopIdAndSysType(@Param("shopId") Long shopId, @Param("sysType") Integer sysType, @Param("warehouseId") Long warehouseId);

    /**
     * 获取商家的默认仓库
     *
     * @param shopId
     * @param sysType
     * @return
     */
    WarehouseVO getDefaultWarehouseIdByShopId(@Param("shopId") Long shopId, @Param("sysType") Integer sysType);

    /**
     * 获取店铺的所有仓库列表
     * @param shopId
     * @param sysType
     * @return
     */
    List<WarehouseVO> listWarehouseByShopId(@Param("shopId") Long shopId, @Param("sysType") Integer sysType);

    /**
     * 批量保存
     * @param warehouseList
     */
    void batchSave(@Param("warehouseList") List<Warehouse> warehouseList);

    /**
     * 获取默认仓库集合
     * @return
     */
    List<WarehouseVO> listDefaultWarehouses();

    /**
     * 获取对应店铺的仓库和门店列表
     * @param shopIds
     * @return
     */
    List<WarehouseVO> listWarehouseAndStationByShopIds(@Param("shopIds") List<Long> shopIds);
}
